package com.example.homework;

import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;

public class OkHttpConnection {

    public void fetchPageContent(String urlString) {
        new Thread(() -> {
            try {
                OkHttpClient client = new OkHttpClient();
                Request request = new Request.Builder().url(urlString).build();
                Response response = client.newCall(request).execute();
                String responseBody = response.body().string();
                // 这里处理返回的网页内容
                System.out.println(responseBody);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }).start();
    }
}
